<?php
class Custom_Action_Helper_AssetsList extends Zend_Controller_Action_Helper_Abstract
{

    public function  direct() {
    }

    public function getList() {
   $module_dir = substr(str_replace("\\","/",$this->getFrontController()->getModuleDirectory()),0,strrpos(str_replace("\\","/",$this->getFrontController()->getModuleDirectory()),'/'));
    $temp = array_diff( scandir( $module_dir), Array( ".", "..", ".svn"));
    $modules = array();
    $controller_directorys = array();
    foreach ($temp as $module) {
        if (is_dir($module_dir . "/" . $module)) {
                array_push($modules,$module);
                array_push($controller_directorys, str_replace("\\","/",$this->getFrontController()->getControllerDirectory($module)));
        }
    }

    foreach ($controller_directorys as $dir) {
        foreach (scandir($dir) as $dirstructure) {
                if (is_file($dir  . "/" . $dirstructure)) {
                        if (strstr($dirstructure,"Controller.php") != false) {
                                include_once($dir . "/" . $dirstructure);
                        }
                }

        }
    }

    $default_module = $this->getFrontController()->getDefaultModule();

    $db_structure = array();

    foreach(get_declared_classes() as $c){
                if(is_subclass_of($c, 'Zend_Controller_Action')){
                        $functions = array();
                        foreach (get_class_methods($c) as $f) {
                                if (strstr($f,"Action") != false) {
                                        array_push($functions,substr($f,0,strpos($f,"Action")));
                                }
                        }
                        $c = strtolower(substr($c,0,strpos($c,"Controller")));

                        if (strstr($c,"_") != false) {
                                $db_structure[substr($c,0,strpos($c,"_"))][substr($c,strpos($c,"_") + 1)] = $functions;
                        }else{
                                $db_structure[$default_module][$c] = $functions;
                        }
                }
    }      
     return $db_structure;
}
       
    
}

